



ALTER    proc approve_po_proc
@purchaseOrder_id int, @user_id varchar(50), @user_group varchar(50)

As

begin
Update Purchase_Order_Hold_Table
SET
Hold_User = @user_id, is_approved = 0
WHERE 
PurchaseOrder_ID = @purchaseOrder_id and Hold_Type = @user_group
end

declare @is_po_approved int
select @is_po_approved = (SELECT count(*) FROM
Purchase_Order_Hold_Table WHERE
PurchaseOrder_ID = @purchaseOrder_id and is_approved = 1)

if(@is_po_approved = 0)
begin

Update Purchase_Order_Table SET POT_Status = 'OPEN'
WHERE PurchaseOrder_ID = @purchaseOrder_id

end







